// 引入 react 依赖
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Text, View, Image, TouchableOpacity, ImageBackground, ScrollView } from 'react-native';

// 引入第三方依赖
import _ from 'lodash';
import pureRender from 'pure-render-decorator';

// antd 按需加载
import { } from '@ant-design/react-native';

// 引入 处理数据 所需文件
import { } from './module.js'

// 引入样式
import Styles from './style.js';

// 引入公用组件
import { RnImage } from '../../components/index.js'

// 引入工具包
import { press, size, ScreenWidth } from '../../util/utils.js'

class Book extends Component {
	static propTypes = {

	}

	constructor(props) {
		super(props)
		this.state = {}
	}

	render() {
		const { data, addBuy } = this.props
		return (
			<View
				style={{
					padding: 10,
					marginBottom: 0,
					backgroundColor: '#fff',
					flexDirection: 'row',
					alignItems: 'flex-start',
				}}

			>
				<View style={{ marginLeft: 15 }}>
					<RnImage resizeMode='cover' style={{ backgroundColor: '#ccc', width: 80, height: 80 }} uri={data.image_url} />
				</View>
				<View style={{
					marginLeft: 15
				}}>
					<Text style={{
						fontSize: 16,
						height: 24,
						color: '#232326',
						lineHeight: 24,
						marginBottom: 5,
					}}>{data.title}</Text>
					<View style={{}}>
						<Text style={{ fontSize: 14, color: '#686868', lineHeight: 20, }}>作  者：{data.author}</Text>
						<Text style={{ fontSize: 14, color: '#686868', lineHeight: 20, }}>出版社：{data.publishing_company}</Text>
						<Text style={{ fontSize: 14, color: '#686868', lineHeight: 20, }}>定  价：RM {data.price}</Text>
						<Text style={{ fontSize: 14, color: '#686868', lineHeight: 20, }}>isbn：{data.isbn}</Text>
						<Text style={{ fontSize: 14, color: '#686868', lineHeight: 20, }}>已  售：{data.sales}</Text>
					</View>
					<TouchableOpacity
						onPress={() => {
							addBuy ? addBuy(data) : null
						}}
						style={{
							width: 100,
							borderWidth: .5,
							borderStyle: 'solid',
							borderColor: '#ddd',
							marginTop: 6,
							borderRadius: 6,
							backgroundColor: '#fff',
						}}
					>
						<Text style={{ fontSize: 14, textAlign: 'center', color: '#61676F', lineHeight: 32, }}>加入代购</Text>
					</TouchableOpacity>
				</View>
			</View>
		)
	}
}

export default pureRender(Book)
